<?php
	chong_pha_hoai();
?>
<?php
	$ssp_td=4;
	$sd=5;
	$so_gioi_han=$ssp_td*$sd;
	if($_GET['trang']=='')
	{
		$vtbd=0;
	}
	else
	{
		$vtbd=($_GET['trang']-1)*$so_gioi_han;
	}
	
	$chuoi_union=tinh_chuoi_union_ppp();
	
	$st=tinh_so_trang($so_gioi_han);
	
	echo "<table border='1'>";
		//$tv="select * from sanpham where (id_loaisp='$_GET[id]' and isActive=1) limit $vtbd,$so_gioi_han";
		$tv=$chuoi_union." limit $vtbd,$so_gioi_han";
		$tv_1=mysql_query($tv);
		while($tv_2=mysql_fetch_array($tv_1))
		{
			for($i=1;$i<=$ssp_td;$i++)
			{
				if($i!=1){$tv_2=mysql_fetch_array($tv_1);}
				if($i==1){echo "<tr>";}
				if($tv_2['ten_sanpham']!="")
				{
					$link_chi_tiet="?thamso=chi_tiet_san_pham&id=$tv_2[id_sanpham]";
					echo "<td align='center'>";
						$link_hinh="images/sanpham/".$tv_2['hinh'];
						echo "<a href='$link_chi_tiet'>";
							echo "<img border=0 src='$link_hinh' height='225' width='175'/>";
						echo "</a>";
						echo "<br>";
						echo "<a href='$link_chi_tiet'>";
							echo "<b>".$tv_2['ten_sanpham']."</b>";
						echo "</a>";
						echo "<br>";
						echo "Giá: ".$tv_2['dongia_sanpham']." VNĐ";
						echo "<br>";
						echo "<form action=''>";
							echo "Số lượng: ";
							echo "<input style='width:50px' value='1' name='solg_nnn'>";
							echo "<br>";
							echo "<div style='overflow:hidden;width:5px;height:3px'></div>";
							echo "<input type='hidden' name='id_sp_nnn' value='$tv_2[id_sanpham]'>";
							echo "<input type='hidden' name='them_vao_gio_nnn' value='them_vao_gio_nnn'>";
							echo "<input type='submit' value='Thêm vào giỏ'>";
						echo "</form>";
					echo "</td>";
				}	
				if($i==$ssp_td){echo "</tr>";}
			}//for
		}//while
		echo "<tr>";
			echo "<td colspan='$ssp_td' align='center'>";
				echo "Trang ";
				for($i=1;$i<=$st;$i++)
				{
					$link="?thamso=xuat&id=$_GET[id]&trang=$i";
					echo "<a href='$link'>";
						echo $i." ";
					echo "</a>";
					echo " ";
				}
			echo "</td>";
		echo "</tr>";
	echo "</table>";
?>